﻿<div>
    <label for="startDate" style="margin-left:15px;">开始日期:</label>
    <input id="startDate" type="text" value="@ViewBag.Date"  class = "hasDatepicker Wdate" onclick = "WdatePicker();" readonly="readonly"/>
    <label for="endDate">结束日期:</label>
    <input id="endDate" type="text" value="@ViewBag.Date"  class = "hasDatepicker Wdate" onclick = "WdatePicker();" readonly="readonly"/>
    <input type="button" id="searchBtn" style="width:50px;" value="查询" />
</div>
<script type="text/javascript">
    $("#searchBtn").click(function () {
        if ($("#startDate").val().toString() > $("#endDate").val().toString()) {
            artDialogAlert("开始日期不得大于结束日期");
            return false;
        }
        var treeObj = $.fn.zTree.getZTreeObj("tree");
        var vehicles = treeObj.getCheckedNodes();
        if (vehicles.length == 0) {
            artDialogAlert("请先选择要查询的车辆或单位");
            return false;
        }
        var v="";
        $.each(vehicles, function (index) {
            if (vehicles[index].sim && vehicles[index].sim!=null) {
                v += (vehicles[index].sim + ";");
            }
        });
        v = v.substring(0, v.length - 1);
        $("#vehicles").val(v);
        var url = $("#reporturl").val()+'?startDate=' + $("#startDate").val() + '&endDate=' + $("#endDate").val();
        //var params='{startDate:"'+$("#startDate").val()+'",endDate:"'+$("#endDate").val()+'",vehicles:"'+v+'"}';
        //var params = 'startDate=' + $("#startDate").val() + '&endDate=' + $("#endDate").val() + '&vehicles=' + v;
        artDialogFormWithCallback(url,
            $("#reporttext").val(),
            "search",
            Number($("#reportwidth").val()),
            Number($("#reportheight").val()),
            null,
            //对话框关闭时执行回调函数清除session
            function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "/ReportCenter/ClearSession",
                    data: {},
                    error: function (data) {
                        artDialogAlert("清楚数据失败");
                    }
                });
            });
    });
</script>